<extend name="Base/base"/>
<block name="main">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            轮播图信息输出表
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="__CONTROLLER__/index">轮播图信息</a></li>
            <li class="active">列表</li>
          </ol>
        </section>
			
        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i>轮播图信息管理</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
					<form class="form-inline" action="__CONTROLLER__/index" method="get">
					  <div class="form-group">
						<div class="input-group">
						  <!-- <input type="text" name="state" class="form-control" id="exampleInputAmount" placeholder="状态"/> -->
						  <select name="state" placeholder="状态" style="width:100px;height:30px;">
							<option value="">全部</option>
							<option value="0">禁用</option>
							<option value="1">启用</option>
						  </select>
						</div>
					  </div>
					  <input type="submit" class="btn btn-primary" value="搜索"/>
					</form> 
				<br/>
                  <table id="tid"  width="300px" class="table table-bordered table-hover">
					<thead>
						<tr>
						  <th style="width:60px">ID</th>
						  <th>图片</th>
						  <th>描述</th>
						  <th>链接地址</th>
						  <th>当前状态</th>
						  <th>添加时间</th>
						  <th>操作</th>
						</tr>
					<thead>
					<tbody>
					   <foreach name="slidelist" item="slide">
							<tr class="slide{$slide.id}">
							  <td>{$slide.id}</td>
							  <td><img src="__PUBLIC__/Admin/Uploads/s_{$slide.pic}" width="100px"/></td>
							  <td>{$slide.desc}</td>
							  <td>{$slide.link}</td>
							  <td>
								<if condition="$slide.state eq 0 ">
									<button onclick="doStart({$slide.id},this);" class="btn btn-xs btn-danger" title="点击启用">禁用</button>
								<else/>
									<button onclick="doStop({$slide.id},this);" class="btn btn-xs btn-primary" title="点击禁用">
										启用
									</botton>
								</if>
							  </td>
							  <td>{$slide.addtime}</td>
							  <td>
								 <a href="javascript:;" onclick="doDel({$slide.id},this)" class="btn btn-xs btn-danger">删除</a> &nbsp;
								<a href="__CONTROLLER__/edit/id/{$slide.id}" class="btn btn-xs btn-primary">编辑</a>
								&nbsp;
								</td>
							</tr>
					   </foreach>
				   </tbody>
                  </table>
                </div><!-- /.box-body -->
                <div class="box-footer clearfix">
				  <a href="__CONTROLLER__/add" class="btn btn-primary">添加轮播图</a>
                  <ul class="pagination pagination-sm no-margin pull-right">
                     <nav aria-label="Page navigation">
                       {$pageinfo}
					</nav>
                  </ul>
                </div>
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row --> 
        </section><!-- /.content -->
</block>     
    
<block name="myscript">
	<script type="text/javascript">
		function doDel(id,obj){
			if(confirm("确定要删除吗？")){
				$.ajax({
						type:'GET',
						url :'__CONTROLLER__/del',
						data:'id='+id,
						dataType:'json',
						success:function(res){
							if(res.b){
								$(obj).parents("tr").remove();
							}
						}
				});
			}
		}
		
		function doStart(id,obj){
			if(confirm("确定启用吗？")){
				$.ajax({
					type:'GET',
					url :'__CONTROLLER__/updateState',
					data:'id='+id,
					dataType:'json',
					success:function(res){
						if(res.b){
							$(obj).replaceWith("<button onclick='doStop({$slide.id},this);' class='btn btn-xs btn-primary' title='点击禁用'>启用</botton>");
						}else{
							alert(res.info);
						}
					}
				});
			}
		}
		
		function doStop(id,obj){
			if(confirm("确定禁用吗？")){
				$.ajax({
					type:'GET',
					url :'__CONTROLLER__/updateState1',
					data:'id='+id,
					dataType:'json',
					success:function(res){
						if(res.b){
							$(obj).replaceWith("<button onclick='doStart({$slide.id},this);' class='btn btn-xs btn-danger' title='点击启用'>禁用</botton>");
						}else{
							alert(res.info);
						}
					}
				});
			}
		}
	</script>
</block>
 